<template>
  <div id="tag-popover">
    <div class="mask" v-show="showPopover" @click="$emit('closeDetail', false)"></div>
    <!-- 标签分类 -->
    <div class="tag-type">
      <a-popover
        trigger="click"
        :placement="placement"
        :visible="showPopover"
        :getPopupContainer=" triggerNode => triggerNode.parentNode"
      >
        <template slot="content">
          <slot></slot>
        </template>
        <template slot="title">
          <slot name="title"><span>{{ titleName }}</span></slot>
        </template>
        <a-button
          icon="right"
          :loading="loading"
          @click="showDetail"
        >{{ titleName }}</a-button>
      </a-popover>
    </div>
  </div>
</template>

<script>
import { Popover } from 'ant-design-vue';

export default {
  name: 'TagPopover',

  components: {
    APopover: Popover
  },

  props: {
    // 是否显示悬浮框和遮罩层
    showPopover: {
      type: Boolean,
      default: false
    },
    // 是否显示loading
    loading: {
      type: Boolean,
      default: false
    },
    // 标题名称
    titleName: {
      type: String,
      default: ''
    },
    // 悬浮框位置
    placement: {
      type: String,
      default: 'right'
    }
  },

  methods: {
    // 歌单分类
    async showDetail() {
      this.$emit('showDetail');
    }
  }
}
</script>

<style lang="less" scoped>
#tag-popover {
  .mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9;
    width: 100%;
    height: 100%;
  }
  .tag-all {
    width: 740px;
    max-width: 740px;
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 2px solid #e6e6e6;
    // align-items: center;
    font-size: 14px;
    &:last-child {
      border-bottom: none;
    }
    .tag-title {
      width: 20%;
      color: #cfcfcf;
      font-size: 24px;
      span {
        font-size: 12px;
        margin-left: 5px;
        cursor: default;
      }
    }
  }
  /deep/.ant-btn {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    border-radius: 20px;
    &:hover {
      color: #ec4141;
      border-color: #ec4141;
    }
    &:focus {
      color: rgba(0, 0, 0, 0.65);
      border-color: #d9d9d9;
    }
  }
  /deep/.ant-popover-title {
    min-height: 70px;
    line-height: 70px;
  }
  /deep/.ant-popover-inner-content {
    padding: 0;
  }
}
</style>